package cn.edu.scau.cmi.xuchuangxiong.composite.consistent;

import java.util.ArrayList;

public class Organization extends Team {
	private ArrayList<Team> members = null;
	private String name;
	private int level;
	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public Organization(String name)
	{
		this.members = new ArrayList<Team>();
		this.name = name;
	}
	
	public void addMember(Team t)
	{
		if(t != null) members.add(t);
	}
	
	public void removeMember(Team t)
	{
		if(t != null) members.remove(t);
	}
	
	public Team getMember(int index)
	{
		if(index < members.size()) 
			return members.get(index);
		else return null;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public void printMember() {
		System.out.println(name);
		this.level++;
		for(Team m : members)
		{
			for(int i = 0; i < this.level; i++)
			{
				System.out.print("   ");
			}
			m.setLevel(this.level);
			m.printMember();
		}
		
	}
	
}
